package cn.azzhu.day06

import java.util.Properties
import org.apache.flink.api.common.serialization.SimpleStringSchema
import org.apache.flink.streaming.api.scala._
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer

/**
 * @author azzhu
 * @create 2020-09-21 23:42:58
 */
object FlinkWriteToKafka {
  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    env.setParallelism(1)

    val stream = env.fromElements("hello", "world")

    stream.addSink(new FlinkKafkaProducer(
      "hadoop105:9092",
      "test",
      new SimpleStringSchema()
    ))

    env.execute("FlinkWriteToKafka")
  }
}
